package com.jic.market.controller.manage;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.request.MaterialCategoryAddRequest;
import com.jic.market.request.MaterialCategoryDeleteRequest;
import com.jic.market.request.MaterialCategoryEditRequest;
import com.jic.market.request.MaterialCategoryQueryRequest;
import com.jic.market.response.MaterialCategoryFirstInfo;
import com.jic.market.service.MaterialCategoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 素材分类管理
 */
@RestController
@RequestMapping("/materialCategory")
public class MaterialCategoryManageController {

    @Autowired
    private MaterialCategoryService materialCategoryService;

    @ApiOperation(value = "分页查询")
    @RequestMapping(value = "queryPage", method = RequestMethod.POST)
    public RestResult<PageResult<MaterialCategoryFirstInfo>> queryPage(@RequestBody MaterialCategoryQueryRequest request) {
        return materialCategoryService.queryPage(request);
    }

    @ApiOperation(value = "添加")
    @RequestMapping(value = "add", method = RequestMethod.POST)
    public RestResult<Long> add(@RequestBody MaterialCategoryAddRequest request) {
        return materialCategoryService.add(request);
    }

    @ApiOperation(value = "编辑")
    @RequestMapping(value = "edit", method = RequestMethod.POST)
    public RestResult<Long> edit(@RequestBody MaterialCategoryEditRequest request) {
        return materialCategoryService.edit(request);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete", method = RequestMethod.POST)
    public RestResult<Long> delete(@RequestBody MaterialCategoryDeleteRequest request) {
        return materialCategoryService.delete(request);
    }


}
